﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ABDLight
{
    public partial class frmChooseAddr : Form
    {
        private aejw.cIni oIniSet = new aejw.cIni(Application.StartupPath + "\\settings.ini");
        public frmChooseAddr()
        {
            InitializeComponent();
          

        }

        private void frmChooseAddr_Load(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                textBox1.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 1.ToString());

            }
            else if (radioButton2.Checked)
            {
                textBox2.ReadOnly = false;
                textBox1.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 2.ToString());
            }
            else if (radioButton3.Checked)
            {
                textBox3.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox1.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 3.ToString());
            }
            else if (radioButton4.Checked)
            {
                textBox4.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox1.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 4.ToString());
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                textBox1.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 1.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox1.Text);

            }
            else if (radioButton2.Checked)
            {
                textBox2.ReadOnly = false;
                textBox1.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 2.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox2.Text);
            }
            else if (radioButton3.Checked)
            {
                textBox3.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox1.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 3.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox3.Text);
            }
            else if (radioButton4.Checked)
            {
                textBox4.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox1.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 4.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox4.Text);
            }

            this.Close();
        }

        public void button1_Click_1(object sender, EventArgs e)
        {
            
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                textBox1.ReadOnly = false;
                textBox1.Focus();
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 1.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox1.Text);
            }

        }

        private void frmChooseAddr_Load_1(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                textBox1.ReadOnly = false;
                textBox1.Focus();
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 1.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox1.Text);

            }
            else if (radioButton2.Checked)
            {
                textBox2.ReadOnly = false;
                textBox2.Focus();
                textBox1.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 2.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox2.Text);
            }
            else if (radioButton3.Checked)
            {
                textBox3.ReadOnly = false;
                textBox3.Focus();
                textBox2.ReadOnly = true;
                textBox1.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 3.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox3.Text);
            }
            else if (radioButton4.Checked)
            {
                textBox4.ReadOnly = false;
                textBox4.Focus();
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox1.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 4.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox4.Text);
            }
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked)
            {
                textBox2.ReadOnly = false;
                textBox2.Focus();
                textBox1.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 2.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox2.Text);
            }
           
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
             if (radioButton3.Checked)
            {
                textBox3.ReadOnly = false;
                textBox3.Focus();
                textBox2.ReadOnly = true;
                textBox1.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 3.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox3.Text);
            }
            
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
           if (radioButton4.Checked)
            {
                textBox4.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox1.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 4.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox4.Text);
            }
        }

        private void frmChooseAddr_Load_2(object sender, EventArgs e)
        {
           
           
        }

        private void frmChooseAddr_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (radioButton1.Checked)
            {
                textBox1.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 1.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox1.Text);

            }
            else if (radioButton2.Checked)
            {
                textBox2.ReadOnly = false;
                textBox1.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 2.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox2.Text);
            }
            else if (radioButton3.Checked)
            {
                textBox3.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox1.ReadOnly = true;
                textBox4.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 3.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox3.Text);
            }
            else if (radioButton4.Checked)
            {
                textBox4.ReadOnly = false;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox1.ReadOnly = true;
                oIniSet.WriteValue("choose_addrmatch", "NowChoose", 4.ToString());
                oIniSet.WriteValue("choose_addrmatch", "NowChooseValue", textBox4.Text);
            }

          
        }

        private void textBox1_Click(object sender, EventArgs e)
        {

                radioButton1.Checked = true;           

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            radioButton2.Checked = true;    
        }

        private void textBox3_Click(object sender, EventArgs e)
        {
            radioButton3.Checked = true;    
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox4_Click(object sender, EventArgs e)
        {
            radioButton4.Checked = true;    
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void frmChooseAddr_KeyPress(object sender, KeyPressEventArgs e)
        {
           
        }

        private void frmChooseAddr_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter )
            { }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Остановить работу программы?", "Внимание!",
                                                                  MessageBoxButtons.OKCancel,
                                                                  MessageBoxIcon.Question);
            if (DialogResult.OK == res)
            {
                ((frmClean)this.Owner).btnCancel_Click(null, null);
                this.Close();
            }
            else
            { this.Close(); }
            
        }

        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Остановить работу программы?", "Внимание!",
                                                                  MessageBoxButtons.OKCancel,
                                                                  MessageBoxIcon.Question);
            if (DialogResult.OK == res)
            {
                ((frmClean)this.Owner).btnCancel_Click(null, null);
                this.Close();
            }
            else
            { this.Close(); }
        }
    }
}
